const mongoose = require('mongoose');

// 导入所有模型
const User = require('./user');
const Message = require('./message');
const Dormitory = require('./dormitory');
const Class = require('./class');
const Teacher = require('./teacher');
const Student = require('./student');
const Grade = require('./grade');
const Attendance = require('./attendance');
const AuditLog = require('./auditLog');
const RefreshToken = require('./refreshToken');

// 导出所有模型
module.exports = {
  User,
  Message,
  Dormitory,
  Class,
  Teacher,
  Student,
  Grade,
  Attendance,
  AuditLog,
  RefreshToken
};

// 确保所有模型都已注册
const ensureModelsRegistered = () => {
  const models = ['User', 'Message', 'Dormitory', 'Class', 'Teacher', 'Student', 'Grade', 'Attendance', 'AuditLog', 'RefreshToken'];
  models.forEach(model => {
    if (!mongoose.models[model]) {
      console.warn(`警告: 模型 ${model} 未注册`);
    }
  });
};

module.exports.ensureModelsRegistered = ensureModelsRegistered;